﻿
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Claims;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Common;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Text;
using Models;
using Bjts.ApiGate;

namespace Web.Controllers
{
  /// <summary>
  /// 试验监督
  /// </summary>
  [Authorize(Roles = "user")]
  [Route("api/[controller]")]
  public class TestSuperviseController : BaseController
  {
    /// <summary>
    /// 获取待试验样品列表
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpGet("[action]")]
    public async Task<IActionResult> GetSampleList()
    {
      var parms = new Dictionary<string, string> { ["testUnitId"] = testUnitId };

      if (!String.IsNullOrWhiteSpace(Request.Query["pageNumber"])) parms["pageNumber"] = Request.Query["pageNumber"];
      if (!String.IsNullOrWhiteSpace(Request.Query["pageSize"])) parms["pageSize"] = Request.Query["pageSize"];

      var res = TestSuperviseApi.GetSampleList(parms);

      return await PublicTool.ReturnSuccess(res);
    }

    /// <summary>
    /// 面部验证记录登记
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    [HttpPost("[action]")]
    public async Task<IActionResult> AddFaceCheck([FromBody] Dictionary<string,string> model)
    {
      var parms = new Dictionary<string, string> { ["testUnitId"] = testUnitId, ["currentUserID"] = uid };
      foreach (var key in model.Keys) parms[key] = model[key];   
      var res = TestSuperviseApi.AddFaceCheck(parms);
      return await PublicTool.ReturnSuccess(res);
    }
  }
}
